#ifndef __OBJ_INL__
#define __OBJ_INL__
#ifndef __WINDOWS__
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#else
typedef int socklen_t;
#endif

Position* Obj::GetPosition(){
    return &m_oPosition;
}

bool Obj::IsMoving(){
    return m_nPathPointNum > 0;
}

short Obj::GetID(){
    return m_nObjID;
}

void Obj::SetID(short nID){
    m_nObjID = nID;
}

OBJTYPE Obj::GetType(){
    return m_eType;
}

void Obj::SetType(OBJTYPE eType){
    m_eType = eType;
}

OBJSTATUS Obj::GetStatus()
{
    return m_eStatus;
}

void Obj::SetStatus(OBJSTATUS eStatus)
{
    m_eStatus = eStatus;
}

short Obj::GetPoolID(){
    return m_nPoolID;
}

void Obj::SetPoolID(short nPoolID){
    m_nPoolID = nPoolID;
}

short Obj::GetManageID(){
    return m_nManageID;
}

void Obj::SetManageID(short nManageID){
    m_nManageID = nManageID; 
}

short Obj::GetFD(){
    return m_nFD;
}

void Obj::SetFD(int nFD){
    m_nFD = nFD;
}

const char* Obj::GetIP()
{
    if(GetType() == TYPE_HUMAN)
    {
        if( m_aryIP[0] == 0)
        {
            struct sockaddr_in addr;
            socklen_t nAddrLen = sizeof(addr);
            getpeername(GetFD(),(struct sockaddr*)&addr, &nAddrLen);
            strncpy(m_aryIP, inet_ntoa(addr.sin_addr),MAX_IP_ADDR_LEN-1);
        }
        return m_aryIP;
    }
    return 0;
}

Scene* Obj::GetScene()
{
    return m_pScene;
}

void Obj::SetScene(Scene* pScene)
{
    m_pScene = pScene;
}

void Obj::AddMonsterObserverNum(short nNum)
{   
    m_nMonsterObserverNum += nNum;
}
void Obj::DelMonsterObserverNum(short nNum)
{
    m_nMonsterObserverNum -= nNum;
}
short  Obj::GetMonsterObserverNum()
{
    return m_nMonsterObserverNum;
}

void Obj::SetCacheAttr(short eAttr, int nVal)
{
    if( m_eType == TYPE_HUMAN || m_eType == TYPE_MONSTER||m_eType == TYPE_PET) 
    {
        if( eAttr <0 || eAttr>= CHAR_CACHE_ATTR_NUMBER)
        {
            return ;
        }
        m_aryCharAttr[eAttr] = nVal;
    }    
}
int Obj::GetCacheAttr(short eAttr)
{
    if( m_eType == TYPE_HUMAN || m_eType == TYPE_MONSTER||m_eType == TYPE_PET) 
    {
        if( eAttr <0 || eAttr>= CHAR_CACHE_ATTR_NUMBER)
        {
            return 0;
        }
        return m_aryCharAttr[eAttr];
    }  
    return 0;
}

void Obj::SetDiaphaneity(char nDiaphaneity)
{
    m_nDiaphaneity = nDiaphaneity;
}

char Obj::SetDiaphaneity()
{
    return m_nDiaphaneity;
}

void Obj::SetForbidMove()
{
    m_eActStatus = NO_MOVE;
}

void Obj::SetMoveBreak()
{
    m_eActStatus = MOVE_BREAK;
}

void Obj::SetFreeMove()
{
    m_eActStatus = FREE_MOVE;
}


#endif //__OBJ_INL__
